home *** CD-ROM | disk | FTP | other *** search
- EVAL
-
- Evaluates integer or Boolean expressions.
-
- Format
-
- EVAL <value1> {[<operation>] [<value2>]} [TO <file>] [LFORMAT=<string>]
-
- Template
-
- VALUE1/A,OP,VALUE2/M,TO/K,LFORMAT/K
-
- Location
-
- C:
-
- EVAL is used to evaluate and print the answer of an integer expression. The
- fractional portion of input values and final results, if any, is truncated
- (cut off). If a non-integer is given as an input value, evaluation stops at
- the decimal point.
-
- <Value1> and <value2> can be decimal (the default), hexadecimal, or octal
- numbers. Hexadecimal numbers are indicated by either a leading Ox or #x.
- Octal numbers are indicated by either a leading 0 or a leading #.
- Alphabetical characters are indicated by a leading single quotation mark (`)
- and are evaluated as their ASCII equivalent.
-
- The LFORMAT keyword specifies the formatting string used to print the answer.
- You can use %X (hexadecimal), %O (octal), %N (decimal), or %C (character).
- The %X and %O options require a number of digits using the LFORMAT keyword,
- you can specify to print a new line by including *N in your string.
-
- The supported operations and their corresponding symbols are shown in the
- following table.
-
- addition
-
- +
-
- subtraction
-
- -
-
- multiplication
-
- *
-
- division
-
- /
-
- modulo
-
- mod, M, m, or %
-
- bitwise AND
-
- &
-
- bitwise OR
-
- |
-
- bitwise NOT
-
- ~
-
- left shift
-
- Ish, L, or |
-
- right shift
-
- rsh, R, or r
-
- negation
-
- -
-
- exclusive OR
-
- xor, X, or x
-
- bitwise equivalence
-
- eqv, E, or e
-
- EVAL can be used in scripts as a counter for loops. In that case, use the TO
- option to send the output of EVAL to a file.
-
- Parentheses can be used in the expressions.
-
- Example 1:
-
- 1> EVAL 64 / 8 + 2
- 10
-
- Example 2:
-
- 1> EVAL 0x5f / 010 LFORMAT="The answer is %X4*N"
- The answer is 000B
- 1>
-
- This divides hexadecimal 5f (95) by octal 10 (8), yielding 000B, the integer
- portion of the decimal answer 11.875. (The 1> prompt appears immediately
- after the 000B if *N is not specified in the LFORMAT string.)
-
- For more examples using the EVAL command, see Chapter 8.
-